<template>
	<div class="mainContent">
		<pathTracking :path="Model.path" />
		<div class="container">
			<!-- 一级tabs -->
			<el-tabs v-model="Model.activeTab" @tab-click="onTabChange">
				<el-tab-pane label="领料单详情" name="1"></el-tab-pane>
				<el-tab-pane label="操作日志" name="2"></el-tab-pane>
			</el-tabs>
			<div class="tabBox">
				<div class="detailsTabsBtn" v-if="Model.OutofstockBtn == 0">
					<p class="itemBtn" @click="Changeoutofstock">出库</p>
				</div>
				<el-row class="detailTable">
					<el-form :inline="true">
						<el-col :sm="24" :md="12" :lg="8" :xl="6" v-for="(item,index) in Model.tabFormInline" :key="index">
							<el-form-item :label="item.label+'：'">{{item.value}}</el-form-item>
						</el-col>
					</el-form>
				</el-row>
				<div class="tabBoxStep">
					<el-steps :active="Model.stepOption.activeStep">
						<el-step :title="item.title" :description="item.description" v-for="(item,index) in Model.stepOption.step" :key="index"></el-step>
					</el-steps>
				</div>
				<el-row class="detailTable">
					<div class="detailTableItemTitle">
						<img class="detailTableImgSmall" src="@/assets/img/flower_brown.png" alt="">
						<p class="text">出库单基础信息</p>
						<img class="detailTableImgNormal" :src="Model.detailTableFrom.src" alt="" @click="toggleTableDetail('detailTableFrom')">
					</div>
					<el-form :inline="true" v-show="Model.detailTableFrom.flag">
						<el-col :sm="24" :md="12" :lg="8" :xl="6" v-for="(item,index) in Model.tableFormInline" :key="index">
							<el-form-item :label="item.label+'：'">{{item.value}}</el-form-item>
						</el-col>
					</el-form>
				</el-row>
				<!-- **********************************************               领料单详情                   ************************************** -->
				<div v-show="Model.activeTab==1">
					<el-row class="detailTable">
						<div class="detailTableItemTitle">
							<img class="detailTableImgSmall" src="@/assets/img/flower_brown.png" alt="">
							<p class="text">领取物料明细 — 应领</p>
							<img class="detailTableImgNormal" :src="Model.tab1TableDetail1.src" alt="" @click="toggleTableDetail('tab1TableDetail1')">
							<!-- <img class="detailTableImgNormal" src="@/assets/img/icon_unfold.png" alt="" v-show="Model.tab1TableDetail1"> -->
						</div>
						<div class="detailTableDetail" v-show="Model.tab1TableDetail1.flag">
							<el-table :data="Model.tableData" border show-summary style="width: 100%;max-height:550px">
								<el-table-column fixed prop="batchNo" label="条码" width="100">
									<template slot-scope="scope">
										<el-button type="text">{{scope.row.batchNo}}</el-button>
									</template>
								</el-table-column>
								<el-table-column 
									v-for="(item,index) in Model.tableHeaderData"
									:key="item.prop"
									:prop="item.prop" 
									:label="item.label" 
									:width="item.width" 
								></el-table-column>
							</el-table>
						</div>
					</el-row>
					<!--出库详情 -->
					<el-row class="detailTable" v-if="Model.Outofstock == 1">
						<div class="detailTableItemTitle">
							<img class="detailTableImgSmall" src="@/assets/img/flower_brown.png" alt="">
							<p class="text">领取物料明细 — 实领</p>
						</div>
						<div class="detailTableDetail">
							<el-table :data="Model.tableDataOutNews" border style="width: 100%;max-height:550px">
								<el-table-column fixed prop="batchNo" label="条码" width="100">
									<template slot-scope="scope">
										<el-button type="text">{{scope.row.batchNo}}</el-button>
									</template>
								</el-table-column>
								<el-table-column 
									v-for="(item,index) in Model.tableHeaderData"
									:key="item.prop"
									:prop="item.prop" 
									:label="item.label" 
									:width="item.width" 
								></el-table-column>
							</el-table>
						</div>
					</el-row>	
					<!--出库操作时 -->
					<el-row class="detailTable" v-if="Model.Outofstock == 0">
						<div class="detailTableItemTitle">
							<img class="detailTableImgSmall" src="@/assets/img/flower_brown.png" alt="">
							<p class="text">领取物料明细 — 实领</p>
						</div>
						<div class="OutofstockSearch">
							<el-row class="rows basic">
								<el-col :sm="12" :md="8" :lg="6" class="ofstockFirst">
									是否手动导入
									<el-radio-group v-model="Model.leadingin">
										<el-radio :label="0">否</el-radio>
										<el-radio :label="1">是</el-radio>
									</el-radio-group>
								</el-col>
								<el-col :sm="12" :md="8" :lg="6" v-show="Model.leadingin!=0">
									<div class="items">
										<div class="btn" @click="importMaterial">添加出库商品</div>
									</div>
								</el-col>
							</el-row>
							<el-row class="rows basic" v-show="Model.leadingin!=1">
								<el-col :sm="12" :md="8" :lg="6">
									<el-input class="input-cont" v-model="Model.writeSku" placeholder="请扫码入库/输入SKU" @keyup.enter.native="checkSku"></el-input>
								</el-col>
								<el-col :sm="12" :md="8" :lg="6">
									<div class="items">
										<div class="btn" @click="checkSku">确认</div>
									</div>
								</el-col>
							</el-row>
							<el-row class="addbtn">
								<div class="cont" @click="deleteTableData">
									<p class="font">删除</p>
								</div>
							</el-row>
						</div>
						<div class="detailTableDetail">
							<el-table :data="Model.tableDataOut" border style="width: 100%;max-height:550px" @selection-change="handleSelectionChange">
								<el-table-column type="selection" width="50" fixed></el-table-column>
								<el-table-column fixed prop="batchNo" label="条码" width="100">
									<template slot-scope="scope">
										<el-button type="text">{{scope.row.batchNo}}</el-button>
									</template>
								</el-table-column>
								<el-table-column 
									v-for="(item,index) in Model.tableHeaderData"
									:key="item.prop"
									:prop="item.prop" 
									:label="item.label" 
									:width="item.width" 
								></el-table-column>
							</el-table>
						</div>
					</el-row>	
				</div>
				<!-- **********************************************               操作日志                   ************************************** -->
				<div v-show="Model.activeTab==2">
					<el-row class="detailTable">
						<div class="detailTableItemTitle">
							<img class="detailTableImgSmall" src="@/assets/img/flower_brown.png" alt="">
							<p class="text">订单操作日志</p>
							<img class="detailTableImgNormal" :src="Model.tab4TableDetail1.src" alt="" @click="toggleTableDetail('tab4TableDetail1')">
						</div>
						<div class="detailTableDetail" v-show="Model.tab4TableDetail1.flag">
							<el-table :data="Model.tableData4" border show-summary style="width: 100%;max-height:550px">
								<el-table-column prop="createTime" label="时间" width="200"></el-table-column>
								<el-table-column prop="type" label="操作类型" width="120"></el-table-column>
								<el-table-column prop="createBy" label="操作人" width="120"></el-table-column>
								<el-table-column prop="record" label="操作记录"></el-table-column>
							</el-table>
						</div>
					</el-row>
				</div>
			</div>
			<el-row class="bottom" v-if="Model.Outofstock == 0">
				<div class="btn_group">
					<div class="btn_item" @click="ToOutofstock">出库</div>
					<div class="btn_item cancel" @click="goBack">取消</div>
				</div>
			</el-row>
		</div>
		<!-- 导入文件 弹窗 -->
		<el-dialog :visible.sync="Model.importFileDialog" class="minDialog">
			<div class="common-table-title">
				<div class="common-table-icon"></div>
				<div class="common-table-fl">导入文件</div>
			</div>
			<div style="background: #fff;">
				<el-row class="common-table-con">
					<div class="fileup-cont">
						<input class="fileup" type="file" name="fileup" id="fileup" v-on:change="fileChange($event)" />
						<div class="fileup-name">{{Model.fileupName}}</div>
						<div class="fileup-btn">浏览</div>
					</div>
				</el-row>
				<el-row class="dialog-btn-group">
					<div class="dialog-btn dialog-btn-confirm" @click="uploadExcel">导入摸板</div>
				</el-row>
				<el-row>
					<p class="template-name" @click="downloadExcel()">下载调拨商品导入模板</p>
				</el-row>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import pathTracking from "@/components/common/pathTracking";
	import pagination from "@/components/common/pagination.vue";
	import advancedSearch from "@/components/common/filter/advancedSearch";
	import {
		getDateString
	} from "@/assets/js/common.js";
	import Model from "./model.js";
	import Controller from "./Controller.js";
	export default {
		name: "purchase",
		mixins: [Model, Controller],
		components: {
			advancedSearch,
			pagination,
			pathTracking
		}
	};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
	@import "./index.less";
</style>
